/**********************************************************************************************
 * @brief USEGE


 ***********************************************************************************************/

#ifndef __filter_kid_bkjl6sdoi7fjwe90e3wf9__
#define __filter_kid_bkjl6sdoi7fjwe90e3wf9__

#include <string>

namespace hude
{
	//---------------------------------------------------------------------------------------------
	struct filter_kid_t
	{
		void send( std::string& buffer )
		{
		}

		void recv( std::string& buffer )
		{
			auto pos = buffer.find( "\"k\"" );

			if( pos == std::string::npos )
				return;
			else
				pos += 3;

			size_t escape, begin_c, end_c;

			escape = begin_c = end_c = 0;

			bool flag = true;

			while( flag && pos < buffer.length() )
			{
				switch( buffer[pos] )
				{
				case ',':
					if( begin_c == 0 )
						flag = false;

					if( end_c != 0 )
						flag = false;

					break;

				case '\"':
					if( escape != pos )
					{
						if( begin_c == 0 )
						{
							begin_c = pos;
						} else {
							end_c = pos;
						}
					}
					break;

				case '\\':
					if( escape != pos )
					{
						escape = pos + 1;
					}

					break;

				default:
					break;
				}

				pos += 1;
			}

			if( begin_c != 0 && end_c != 0 )
			{
				buffer[begin_c++] = '0';
				end_c += 1;

				while( end_c < buffer.length() )
				{
					buffer[begin_c++] = buffer[end_c++];
				}

				buffer.resize( begin_c );
			}
		}
	};

} //namespace hude

#endif //__filter_kid_bkjl6sdoi7fjwe90e3wf9__
//file end

